{% extends 'base.html' %}

{% block title %}
  Добавление новости :: {{ block.super }}
{% endblock %}

{% block sidebar %}
  {% include 'inc/_sidebar.html' %}
{% endblock %}

{% block content %}
  <h1>Добавление новости</h1>
  <form action="{% url 'add_news' %}" method="post">
    {% csrf_token %}

    {{ form.as_p }}


    {{ form.non_field_errors }}

    {% comment %}
    <div class="mb-3 form-group">
      <label for="{{ form.title.id_for_label }}" class="form-label">Название: </label>
      {{ form.title }}
      <div class="invalid-feedback">
        {{ form.title.errors }}
      </div>
    </div>

    <div class="mb-3 form-group">
      <label for="{{ form.content.id_for_label }}" class="form-label">Текст: </label>
      {{ form.content }}
      <div class="invalid-feedback">
        {{ form.content.errors }}
      </div>
    </div>

    <div class="mb-3 form-group">
      <label for="{{ form.is_published.id_for_label }}" class="form-label">Опубликовано? </label>
      {{ form.is_published }}
      <div class="invalid-feedback">
        {{ form.is_published.errors }}
      </div>
    </div>

    <div class="mb-3 form-group">
      <label for="{{ form.category.id_for_label }}" class="form-label">Категория: </label>
      {{ form.category }}
      <div class="invalid-feedback">
        {{ form.category.errors }}
      </div>
    </div>
    {%  endcomment %}


    {% comment %}
    {% for field in form %}
      <div class="mb-3 form-group">
        {{ field.label_tag }}
        {{ field }}
        <div class="invalid-feedback">
          {{ field.errors }}
        </div>
      </div>
    {% endfor %}
    {%  endcomment %}

    <button type="submit" class="btn btn-primary btn-block">Добавить новость</button>
  </form>
{% endblock %}


